package com.lagou.boot;

import com.lagou.client.RPCConsumer;
import com.lagou.request.RpcRequest;
import com.lagou.service.IUserService;

import java.lang.reflect.InvocationTargetException;

public class ConsumerBoot {

    //参数定义
    private static final String PROVIDER_NAME = "UserService#sayHello#";

    public static void main(String[] args) throws InterruptedException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {

        //1.创建代理对象
        IUserService service = (IUserService) RPCConsumer.createProxy(IUserService.class);

        //2.循环给服务器写数据
        while (true){
            RpcRequest request = new RpcRequest();
            request.setClassName("userServiceImpl");
            request.setMethodName("calldemo");
            request.setParameters(new String[]{"call sucess"});
            request.setParameterTypes(new Class[]{String.class});
            request.setRequestId("1");
            RpcRequest result = service.sayHello(request);
            System.out.println(result.getParameters()[0].toString());
            Thread.sleep(2000);
        }

    }
}
